# 网络管理
# 一、TCP
# IP Forwarding
IPEnableRouter (opens new window) 用于全局控制整个系统的 IP 转发功能。
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" `
-Name IPEnableRouter `
-Type DWord `
-Value 1
查看单个网络接口的转发功能。
Get-NetIPInterface `
| Select-Object -Property ifIndex, InterfaceAlias, AddressFamily, ConnectionState, Forwarding `
| Sort-Object -Property ifIndex `
| Format-Table
启用所有网络接口的转发功能。
Set-NetIPInterface -Forwarding Enabled
启用远程访问服务。
Set-Service RemoteAccess -StartupType Automatic
Start-Service RemoteAccess
# Active Probe
系统无法正确判断网络连接状态时,通过调整注册表配置,让系统不去主动探测网络连接状态。
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" `
-Name EnableActiveProbing `
-Type DWord `
-Value 0
# 二、远程桌面服务
# Listening Port
远程桌面的侦听端口 (opens new window)默认为 3389,可以通过修改注册表来更改。
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" `
-Name PortNumber `
-Type DWord `
-Value 3389
# 三、命令
# 路由配置
route (opens new window) 命令用于显示和修改本地 IP 路由表中的项。
查看路由表。
route print -4
添加路由。
route add 192.168.11.0 mask 255.255.255.0 192.168.10.245 -p
删除路由。
route delete 192.168.11.0 mask 255.255.255.0
# 网络接口
Network Shell (opens new window) 以本地或远程方式显示或修改当前正在运行的计算机的网络配置。
netsh interface (opens new window)
配置网络接口。
# 查找网络接口的名称或索引 netsh interface show interface netsh interface ipv4 show interfaces # 禁用或启用有线连接 netsh interface set interface "YourInterfaceName" admin=disable netsh interface set interface "YourInterfaceName" admin=enable-
配置和管理无线连接和安全设置。
# 断开与无线网络的连接 netsh wlan disconnect
# 路由跟踪
tracert (opens new window) 向目标发送 ICMP 请求,并以递增的 TTL 字段值来确定到达目标的路径。
tracert 1.1.1.1